<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const dictionary = Object.create(null);
      dictionary.apple = "Apple";
      dictionary.__proto__ = "test";
      //   dictionary.toString = function () {
      //     return Object.keys(this).join(",");
      //   };
      //   Object.defineProperty(dictionary, "toString", {
      //     value: function () {
      //       return Object.keys(this).join(",");
      //     },
      //     enumerable: false,
      //   });
      dictionary[Symbol.toPrimitive] = function () {
        return Object.keys(this).join(",");
      };

      for (let key in dictionary) {
        console.log(key);
      }

      // 对象->原始（基本）数据类型
      console.log(dictionary + ",!!"); //apple,__proto__,!!
    </script>
  </body>
</html>
